package com.example.jhweather.Module;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;

import androidx.annotation.NonNull;
import androidx.drawerlayout.widget.DrawerLayout;

import com.example.jhweather.Base.BaseActivity;
import com.example.jhweather.R;
import com.google.android.material.navigation.NavigationView;

public class MainActivity extends BaseActivity {

    private DrawerLayout drawerLayout;
    private NavigationView navigationView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //绑定视图
        initView();

        //初始化数据
        initData();


    }

    private void initView() {
        drawerLayout = findViewById(R.id.drawer_main);
        navigationView = findViewById(R.id.nav_main);
    }

    private void initData() {
        navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                switch (item.getItemId()){
                    case R.id.nav_login:
                        Intent intent = new Intent(MainActivity.this,LoginActivity.class);
                        startActivity(intent);
                        finish();
                    case R.id.nav_city:
                        intent = new Intent(MainActivity.this,CityActivity.class);
                        startActivity(intent);
                    case R.id.nav_set:
                        intent = new Intent(MainActivity.this,SetActivity.class);
                        startActivity(intent);

                }
                return false;
            }
        });
    }
}